package com.example.studyplanning.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.example.studyplanning.entity.Clock;

import java.util.List;

@Mapper
public interface ClockMapper {
    @Insert("insert into clock(userID) values (#{userID})")
    Integer InsertClock(Integer userID);

    @Select("select user.userName,DATE_FORMAT(clock.clockDate,'%Y-%m-%d') as date_time from clock join user on clock.userID=user.userID where clock.userID=#{userID}")
    List<Clock> FindClock(Integer userID);

    @Select("select user.userName,DATE_FORMAT(clock.clockDate,'%Y-%m-%d') as date_time from clock join user on clock.userID=user.userID where clock.userID=#{userID} and DATE_FORMAT(clock.clockDate,'%Y-%m-%d')='${date_time}'")
    List<Clock> FindByDate(@Param("userID")Integer userID,@Param("date_time")String date_time);
}
